package com.example.gmranqi.controller;

import com.example.gmranqi.common.JsonMapper;
import com.example.gmranqi.response.PageResult;
import com.example.gmranqi.service.BigScreenService;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "光明燃气大屏接口")
@RestController
@RequestMapping("/api/bigScreen")
public class BigScreenController {

    @Autowired
    private BigScreenService bigScreenService;

    private JsonMapper jm = new JsonMapper(JsonInclude.Include.ALWAYS);


    @ApiOperation(value = "001-查询部门树状图（0-职能部门，1-行政区划）-RQAQ.SYS_DEPARTMENT")
    @GetMapping("queryDepartTree")
    public String queryDepartTree(@RequestParam int IS_DISTRICT) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.queryDepartTree(IS_DISTRICT);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "002-中间街道地图统计")
    @GetMapping("countMapByStreet")
    public String countByStreet() {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.countMapByStreet();
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "003-按选择行政区进行统计")
    @GetMapping("countByDepartIdAndLevel")
    public String countByDepartIdAndLevel(@RequestParam Long ID ,@RequestParam Integer LEVELS) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.countByDepartIdAndLevel(ID,LEVELS);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "004-安全巡检-按选择行政区进行统计")
    @GetMapping("countInspectionByDepartIdAndLevel")
    public String countInspectionByDepartIdAndLevel(@RequestParam Long ID ,@RequestParam Integer LEVELS) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.countInspectionByDepartIdAndLevel(ID,LEVELS);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "005-安全巡检-部门按月检查折线图（TYPE:1-巡检任务，2-督导，3-隐患）",notes = "{\n" +
            "\"ID\":0,\n" +
            "\"LEVELS\":0,\n" +
            "\"TYPE\":3,\n" +
            "\"DEPT_ID\":1836217960963078888\n" +
            "}")
    @PostMapping("countInspectionByMonth")
    public String countInspectionByMonth(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.countInspectionByMonth(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    //1储配站数 ,2 供应站数,3服务点数
    @ApiOperation(value = "011-查询燃气站点-RQAQ.G_GAS_SITE")
    @PostMapping("query_G_GAS_SITE")
    public String query_G_GAS_SITE(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.query_G_GAS_SITE(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "012-查询燃气用户-RQAQ.G_GAS_USER")
    @PostMapping("query_G_GAS_USER")
    public String query_G_GAS_USER(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.query_G_GAS_USER(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "013-查询第三方工地-RQAQ.G_THIRD_PARTY_SITE")
    @PostMapping("query_G_THIRD_PARTY_SITE")
    public String query_G_THIRD_PARTY_SITE(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.query_G_THIRD_PARTY_SITE(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "014-查询巡检记录/任务-RQAQ.G_RQAQ_TASK")
    @PostMapping("query_G_RQAQ_TASK")
    public String query_G_RQAQ_TASK(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.query_G_RQAQ_TASK(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "014-2-查询巡检记录/任务(含坐标)-RQAQ.G_RQAQ_TASK")
    @PostMapping("queryTaskWithPoints")
    public String queryTaskWithPoints(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.queryTaskWithPoints(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "015-查询燃气管道-RQAQ.G_GAS_PIPE")
    @PostMapping("query_G_GAS_PIPE")
    public String query_G_GAS_PIPE(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.query_G_GAS_PIPE(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "016-查询本月巡检次数+本月督导次数+隐患数量+已整改数量+所属区域",notes = "{\"type\":1,\"id\":1821373250883858432}")
    @PostMapping("queryDetailCount")
    public String queryDetailCount(@RequestBody Map<String,Object> queryMap) {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.queryTaskDetailCount(queryMap);
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    /*@ApiOperation(value = "025-查询部门表-RQAQ.SYS_DEPARTMENT")
    @GetMapping("query_SYS_DEPARTMENT")
    public String query_SYS_DEPARTMENT() {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.query_SYS_DEPARTMENT();
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }

    @ApiOperation(value = "100-查询行政处罚管理-RQAQ.G_ADMINISTRATION")
    @GetMapping("query_G_ADMINISTRATION")
    public String query_G_ADMINISTRATION() {
        long st = System.currentTimeMillis();
        PageResult pr = bigScreenService.query_G_ADMINISTRATION();
        pr.setTime(System.currentTimeMillis() - st);
        return jm.toJson(pr);
    }
*/
}
